package com.romain.risotto.texture;

import org.andengine.opengl.texture.TextureManager;
import org.andengine.opengl.texture.TextureOptions;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.texture.region.ITiledTextureRegion;
import org.andengine.opengl.texture.region.TextureRegion;

import android.content.Context;

public class Textures {

	public static ITextureRegion textureShip;
	public static ITiledTextureRegion textureGaz;
	public static ITextureRegion textureBullet;
	public static ITextureRegion textureExplosion;
	
	public static ITextureRegion textureBG;

	
	
	public static ITextureRegion texturePad;
	public static ITextureRegion textureBouton;
	public static TextureRegion textureRoc1;
	public static TextureRegion textureRoc2;

	public static void load(TextureManager textureManager, Context context) {
		BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");

		BitmapTextureAtlas atlasShip = new BitmapTextureAtlas(textureManager,
				40,47, TextureOptions.BILINEAR);
		textureShip = BitmapTextureAtlasTextureRegionFactory.createFromAsset(
				atlasShip, context, "ship2.png", 0, 0);
		atlasShip.load();

		BitmapTextureAtlas atlasBul = new BitmapTextureAtlas(textureManager,
				10, 10, TextureOptions.BILINEAR);
		textureBullet = BitmapTextureAtlasTextureRegionFactory.createFromAsset(
				atlasBul, context, "bullet1.png", 0, 0);
		atlasBul.load();

		BitmapTextureAtlas atlasExplosion = new BitmapTextureAtlas(
				textureManager, 72, 72, TextureOptions.BILINEAR);
		textureExplosion = BitmapTextureAtlasTextureRegionFactory
				.createFromAsset(atlasExplosion, context, "explosion.png", 0, 0);
		atlasExplosion.load();

		BitmapTextureAtlas atlasGaz = new BitmapTextureAtlas(textureManager,
				20, 24, TextureOptions.BILINEAR);
		textureGaz = BitmapTextureAtlasTextureRegionFactory
				.createTiledFromAsset(atlasGaz, context, "gaz.png", 0, 0, 2, 1);
		atlasGaz.load();

		BitmapTextureAtlas atlasPad = new BitmapTextureAtlas(textureManager,
				256, 128, TextureOptions.BILINEAR);
		texturePad = BitmapTextureAtlasTextureRegionFactory.createFromAsset(
				atlasPad, context, "onscreen_control_base.png", 0, 0);
		textureBouton = BitmapTextureAtlasTextureRegionFactory.createFromAsset(
				atlasPad, context, "onscreen_control_knob.png", 128, 0);
		atlasPad.load();
		
		BitmapTextureAtlas atlasBG = new BitmapTextureAtlas(textureManager, 300, 300,TextureOptions.REPEATING_BILINEAR);
		textureBG = BitmapTextureAtlasTextureRegionFactory.createFromAsset(atlasBG, context, "bg1.jpg", 0, 0);
		atlasBG.load();
		
		BitmapTextureAtlas atlasAst = new BitmapTextureAtlas(textureManager, 100, 98,TextureOptions.NEAREST);
		textureRoc1 = BitmapTextureAtlasTextureRegionFactory.createFromAsset(atlasAst, context, "asteroid1.png", 0, 0);
		atlasAst.load();
		atlasAst = new BitmapTextureAtlas(textureManager, 100, 96,TextureOptions.NEAREST);
		textureRoc2 = BitmapTextureAtlasTextureRegionFactory.createFromAsset(atlasAst, context, "asteroid2.png", 0, 0);
		atlasAst.load();
	}

}
